        TTL     > FS00

; ***********************************
; ***    C h a n g e   L i s t    ***
; ***********************************

; Date       Name  Description
; ----       ----  -----------

; 19-Oct-88  SKS   0.06 Remove debug on services and fscv
; 12-Nov-88  SKS   0.07 Really remove debug conditionally
;                  0.08 Add *List
; 15-Nov-88  SKS   0.09 Add arg to *Reset, fix *Help
; 01-Dec-88  SKS   0.10 Fixed *Cat to not print garbage
;                  0.11 Fixed *Run to EXEC -1 files; added *Back, *CDir
;                       *Compact, *Bye
; 05-Dec-88  SKS   0.12 Fixed *Run to not go Bad String all the time
; 06-Dec-88  SKS   0.13 Added *ex, initially synonymous with *cat
; 14-Dec-88  SKS   0.14 Fixed *Reset syntax message, added FSBrk routine
; 15-Dec-88  SKS   0.15 Removed several commands, use with DNFS300_e
; 16-Dec-88  SKS   0.16 Made Delete and Remove fs commands not utility
;                       Improved FSCat, *Ex formatting for FS dependent things
; 17-Dec-88  SKS   0.17 Attempts to make DFS emulation better
;                  0.18 More of the same. Fixed corker bug in the Pull macro!
; 19-Dec-88  SKS   0.19 Made GBPB 5,6,7 work on DFS, started on GBPB 8
; 20-Dec-88  SKS   0.20 Made *Run use library on DFS
;                  0.21 Made DFS name translation use table so it's patchable
; 21-Dec-88  SKS   1.00 Release for RISC OS Welcome Discs

                GBLS    $version
$version        SETS    "1.00 (21 Dec 1988)"

; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

        GBLL    $True
$True   SETL    1=1

        GBLL    $False
$False  SETL    :LNOT: $True

        GBLL    $debug
$debug  SETL    $False

                GBLL    $debugservice
$debugservice   SETL    $debug :LAND: $False

                GBLL    $debugfs
$debugfs        SETL    $debug :LAND: $True

; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

LF      *       10
CR      *       13
space   *       " "

; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; 6502 instructions

cBRK    *       &00
cNOP    *       &EA

        CPU     1               ; Use CMOS opcodes

ar_cli   * &03                  ; Illegal 6502 opcodes used to talk to emulator
ar_byte  * &13
ar_word  * &23
ar_wrch  * &33
ar_rdch  * &43
ar_file  * &53
ar_args  * &63
ar_bget  * &73
ar_bput  * &83
ar_gbpb  * &93
ar_find  * &A3
ar_exit  * &B3
ar_basic * &C3
ar_insv  * &D3
ar_remv  * &E3
ar_cnpv  * &F3

; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; Zero page allocation

 [ $debug
debugloc *      &9F             ; In Econet zp workspace
 ]

        ^       &A0             ; Current NMI owner workspace. Unused by ARFS


        ^       &A8             ; FS utils workspace
vstrptr #       2
cliptr  #       2
himemptr #      2
pwptr   *       himemptr        ; NOT cliptr !
flag    *       himemptr
number  #       2
 ASSERT @ <= &B0


        ^       &B0             ; Scratch space
fstmp   #       2
 ASSERT @ <= &C0


        ^       &C0             ; Current filing system workspace
currfs  #       1
cbptr   #       2
fscptr  *       cbptr
osf_load #      2
osf_save *      osf_load
ncolumns *      osf_load
tcolumns *      osf_load+1
catftype #      1               ; object type - 1
attrfield #     1
nfound   #      1
 ASSERT @ <= &D0


; MOS zp workspace

osw_A   *       &EF
osw_X   *       &F0
osw_Y   *       &F1
os_cliptr *     &F2             ; Pointer to current oscli command
ROMid   *       &F4             ; Currently selected ROM
brkptr  *       &FD             ; Pointer to BRK number,string,0
escflag *       &FF

; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; OS workspace

        ^       &0200
userv   #       2
brkv    #       2
irq1v   #       2
irq2v   #       2
cliv    #       2
bytev   #       2
wordv   #       2
wrchv   #       2
rdchv   #       2
filev   #       2
argsv   #       2
bgetv   #       2
bputv   #       2
gbpbv   #       2
findv   #       2
fscv    #       2
eventv  #       2
uptv    #       2
netv    #       2
vduv    #       2
keyv    #       2
insv    #       2
remv    #       2
cnpv    #       2
ind1v   #       2
ind2v   #       2
ind3v   #       2

RTypeTable *    &02A1
RPrivTable *    &0DF0

; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; Static workspace allocation. May only be used when we are the current fs
; and have claimed it

        ^       &0E00

osf_buffer  #   512

           #    2
fil_blk    #    0
fil_name   #    2
gbpb_catblk #   0               ; Start here for when we do gbpb 10 for catinfo
 ASSERT (gbpb_catblk :AND: 3) = 0 ; Word aligned!
fil_load   #    4
fil_exec   #    4
fil_start  #    4
fil_length *    fil_start
fil_end    #    4
fil_attr   *    fil_end
gbpb_objtype #  4
gbpb_retname #  11


gbpb_blk     #  0
gbpb_handle  #  1
gbpb_addr    #  4
gbpb_nbytes  #  4
gbpb_seqptr  #  4
gbpb_dirname #  4
gbpb_wildpat #  4

dfsdrive     #  1       ; Textual drive number of CSD drive
             #  1       ; Terminator
dfsdir       #  1

dfsldrive    #  1       ; Textual drive number of library drive
             #  1       ; Terminator
dfslib       #  1

tmpdrive     #  1       ; Textual drive number of temporary drive
             #  1       ; Terminator
tmpdir       #  1

namecount    #  1

dfsname      #  (:LEN:"0.DSevenCh") + 1

 ! 0,"End of static workspace at ":CC:(:STR:@)

; If we want DFSability, don't allocate beyond &1100 !


        #       &1700-@         ; Similar to DFS allocation

Abs_Size  *     @-&0E00
Abs_Pages *     (Abs_Size + 255) / 256

 ! 0,"Claiming ":CC:(:STR:Abs_Pages):CC:" static pages"

; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; Dynamic workspace allocation

        ^       0
d_dfsdrive   #  1
d_dfsdir     #  1
d_dfsldrive  #  1
d_dfslib     #  1

 ! 0,"End of dynamic workspace at ":CC:(:STR:@)

        #       &0200-@         ; Similar to DFS allocation
                                ; We may wish to remove this now

Dyn_Size  *     @
Dyn_Pages *     (Dyn_Size + 255) / 256

 ! 0,"Claiming ":CC:(:STR:Dyn_Pages):CC:" dynamic pages"

; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

SVIA_IER *      &FE4E

; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; MOS entry points

osrdrm  *       &FFB9
oseven  *       &FFBF
gsinit  *       &FFC2
gsread  *       &FFC5
nvwrch  *       &FFC8
nvrdch  *       &FFCB
osfind  *       &FFCE
osgbpb  *       &FFD1
osbput  *       &FFD4
osbget  *       &FFD7
osargs  *       &FFDA
osfile  *       &FFDD
osrdch  *       &FFE0
osasci  *       &FFE3
osnewl  *       &FFE7
oswrch  *       &FFEE
osword  *       &FFF1
osbyte  *       &FFF4
oscli   *       &FFF7

; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; OSByte reason codes

B_KbSc16 *      &7A             ; Scan keyboard from 16 decimal
B_Language *    &8E             ; Start language X
B_Service *     &8F             ; Issue service X, arg Y
B_ExtVectors *  &A8             ; Read YX -> extended vector base

; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; FSCV reason codes

FSC_OPT    *    0
FSC_EOF    *    1
FSC_Slash  *    2
FSC_Cmd    *    3
FSC_RUN    *    4
FSC_CAT    *    5
FSC_Die    *    6
FSC_Handle *    7
FSC_Enable *    8   

; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; Filing system id numbers

fs_dfs  *       4
fs_nfs  *       5
fs_adfs *       8
fs_arfs *       11              ; We pretend to be wdfs

; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

        MACRO
$label  Push    $ptr,$reg
        LCLS    $reg2
 [ "$reg" <> ""
$reg2   SETS    "$reg"
 |
$reg2   SETS    "A"
 ]
$label  LD$reg2 $ptr
        PH$reg2
        LD$reg2 ($ptr)+1
        PH$reg2
        MEND


        MACRO
$label  Pull    $ptr,$reg
        LCLS    $reg2
 [ "$reg" <> ""
$reg2   SETS    "$reg"
 |
$reg2   SETS    "A"
 ]
$label  PL$reg2
        ST$reg2 ($ptr)+1
        PL$reg2
        ST$reg2 $ptr
        MEND


        MACRO
$label  GENAD   $addr
$label  LDXIM   :LSB: ($addr)
        LDYIM   :MSB: ($addr)
        MEND


        MACRO
$label  STXY    $addr
$label  STX     $addr
        STY     ($addr)+1
        MEND


        MACRO
$label  LDXY    $addr
$label  LDX     $addr
        LDY     ($addr)+1
        MEND

; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

        LNK     FS01
